<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <button tag="login" id="button">点击打开登录浮层</button>
        <script>

        var showLogin = function(){
          console.log( '打开登录浮层' );
          log( this.getAttribute( 'tag' ) );
        }

        var log = function( tag ){
          console.log( '上报标签为： ' + tag );
          // (new Image).src = 'http://xxx.com/report? tag=' + tag;    // 真正的上报代码略
        }
        document.getElementById( 'button' ).onclick = showLogin;

        </script>
</body>
</html>